<ui:composition xmlns="http://www.w3.org/1999/xhtml"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:p="http://primefaces.org/ui"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:util="http://java.sun.com/jsf/composite/util"
                xmlns:f="http://java.sun.com/jsf/core">

    <h:form id="users_list_form">
        <util:dataTableWrapper title="Lista utilizatori">
            <f:facet name="buttonContent">
                <p:commandButton icon="custom-icon-add" value="Adauga utilizator nou"
                                 oncomplete="PF('add_contract_WV').show()" update=":create_user_form"
                                 resetValues="true"
                                 actionListener="#{userAdministrationBean.resetCreateUserDialog}"/>
            </f:facet>

            <f:facet name="rightContent">
                <p:outputPanel layout="block">
                    <p:watermark for="search-input" value="cauta utilizator dupa:(nume,prenume,e-mail)"/>
                    <p:inputText id="search-input" style="width: 240px;margin-right: 5px"/>
                    <p:commandButton value="Cauta"/>
                </p:outputPanel>
            </f:facet>

            <p:dataTable id="users_table" var="u" value="#{userAdministrationBean.users}"
                         emptyMessage="Nu a fost gasita nici o inregistrare."
                         paginator="true" paginatorPosition="bottom" rowsPerPageTemplate="5,10,15" rows="10"
                         paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}">

                <p:column headerText="Nume" sortBy="#{u.folder.lastName}">
                    <h:outputText value="#{u.folder.firstName} #{u.folder.lastName} #{u.folder.patronymic}"/>
                </p:column>

                <p:column headerText="Adresa de e-mail">
                    <h:outputText value="#{u.email}"/>
                </p:column>

                <p:column headerText="Activ">
                    <h:outputText value="#{u.enabled ? 'Da' : 'Nu'}"/>
                </p:column>

                <p:column styleClass="override-icons" headerText="Actions">
                    <p:commandButton icon="custom-icon-edit" value="Editeaza"
                                     actionListener="#{userAdministrationBean.setSelectedUser(u)}"
                                     oncomplete="PF('add_user_WV').show()" update=":create_user_form"/>

                    <p:commandButton icon="custom-icon-delete" value="Sterge"
                                     actionListener="#{userAdministrationBean.deleteUser(u)}"
                                     update="@form">
                        <p:confirm header="Confirma"
                                   message="Sunteti sigur ca doriti stergerea utilizatorului selectat?"
                                   icon="ui-icon-alert"/>
                    </p:commandButton>
                </p:column>
            </p:dataTable>
        </util:dataTableWrapper>

        <p:confirmDialog global="true">
            <p:commandButton value="Da" type="button" styleClass="ui-confirmdialog-yes" icon="ui-icon-check"/>
            <p:commandButton value="Nu" type="button" styleClass="ui-confirmdialog-no" icon="ui-icon-close"/>
        </p:confirmDialog>
    </h:form>
</ui:composition>